package com.pension.servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.pension.common.Util;
import com.pension.model.dao.MemberDao;
import com.pension.model.dto.Member;

@WebServlet("/member/modify.action")
public class ModifyServlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		
		String memberId = req.getParameter("memberId");
		String passwd = req.getParameter("passwd");
		passwd = Util.getHashedString(passwd, "SHA-1");
		String email = req.getParameter("email");
		String phone1 = req.getParameter("phone1");
		
		Member member = new Member();
		member.setMemberId(memberId);
		member.setPasswd(passwd);
		member.setEmail(email);
		member.setPhone1(phone1);
		
		
		MemberDao dao = new MemberDao();
		dao.getModifyMember(passwd, email, phone1, memberId);
		
		//등록 후 목록 화면으로 이동
		//HttpResponse.sendRedirect: 지정된 경로로 요청을 재전송
		resp.sendRedirect("/pension/member/view.action?memberid=" + memberId);
		
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
		throws ServletException, IOException {
		
		req.setCharacterEncoding("utf-8");
		
		doGet(req, resp);
	}
	
}






